package main

import "fmt"

func main() {
	var a int = 1
	if a == 1 {
		fmt.Print("a的确等于1")
	} else if a == 2 {
		fmt.Print("a确实等于22")
	} else {
		fmt.Print("over")
	}
	str := "Go is a beautiful language!"
	for pos, char := range str {
		fmt.Printf("Character on position %d is: %c \n", pos, char)

	}
	//空白占位符
	var int1 int
	var f1 float32
	int1, _, f1 = three()
	fmt.Print(f1, int1)
	callback(1, Add)
	v := make([]int, 10, 50)
	//切片定义
	fmt.Print(len(v), cap(v))

	var P person // P现在就是person类型的变量了
	P.name = "asd"
	P.age = 25                                     // 赋值"25"给变量P的age属性
	fmt.Println("The person's name is %s", P.name) // 访问P的name属性.
	//回调

}

func three() (int, int, float32) {
	return 1, 2, 3.2
}
func callback(i1 int, f func(int)) {
	f(i1)

}
func Add(i1 int) {
	fmt.Print(i1)
}

//defer 用于等待某些特定的返回数值
func function1() {
	fmt.Printf("In function1 at the top\n")
	defer three()
	fmt.Printf("In function1 at the bottom!\n")
}

type person struct {
	name string
	age  int
}
